package com.cl.master.mapper;

import com.cl.master.domain.Note;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Author xc
 * @Date 2023/5/9 22:38
 * @Version 1.0
 */
@Mapper
@Component//idea高版本不会警告错误，可省略
public interface NoteMapper {

    @Insert("INSERT INTO notes (title, subhead, content) VALUES (#{title}, #{subhead}, #{content})")
    void saveNote(Note note);

    @Select("SELECT * FROM notes")
    List<Map<String, Object>> getNote();

    // @Delete("DELETE FROM notes WHERE title = '${title}'")
    // void deleteNote(String title);

    @Delete("DELETE FROM notes WHERE title = #{title}")
    void deleteNote(String title);

}
